using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;
namespace TurbaconPhone
{
    public class Ball : KineticGameObject
    {
        SoundEffect kick2;
		GameplayState gps;
        public Ball(string textureName, Vector2 pos, GameplayState g)
            : base(textureName, pos)
        {
            MakeCircle(1);
            Body.SetLinearDamping(1);
            Fixture.SetRestitution(1);
            Fixture.SetFriction(0);
            HasTrail = true;
            TrailColor = Color.Blue;
            TrailTexture = TurBacon.Content.GetTexture("solidCircle");
            kick2 = TurBacon.Content.GetSound("kick2");
            gps = g;
           
        }
        public override void Bump(object obj)
        {
            if (obj is Wall)
            {
                Wall wall = (Wall)obj;
                wall.Health -= Vel.Length();
                //Die();
            }
            //OnFire = false;
            bumpSound.Play();
            base.Bump(obj);
        }
        public override void Die()
        {
            new Explosion("explosion", Pos);
            base.Die();
        }
        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);
            //DebugDraw(TurBacon.Batch);
        }
        public void KickBall(Vector2 vel, Character kicker)
        {
            Vel = vel;
            /*if (OnFire&&!kicker.OnFire)
            {
                new Fire("explosion", 3, kicker, 0.5f);
                new Smoke("smoke", 3, kicker, 1f);
            }*/
            //if (!TurBacon.GameInfo.theBall.OnFire)
            //{
            //    new Fireball("explosion", 1, this, 0.5f);
            //    new Exhaust("smoke", 1, this, 0.2f);
            //}
        }

        public void SpecialKick(Vector2 vel, Character kicker)
        {
            Vel = vel;
            if (kicker.AbilityTimer != 0)
                return;
            //kicker.TrailColor = Color.LimeGreen;
            kicker.AbilityUsed();

            gps.ReflexTime(vel, kicker);

            switch (kicker.playerType)
            {
                case PlayerType.forward:
                    if (!TurBacon.GameInfo.theBall.OnFire)
                    {
                        new Fireball("explosion", 5, this, 0.5f);
                        new Exhaust("smoke", 5, this, 0.5f);
                        
                        kick2.Play();
                    }
                    break;
            }
        }
    }
}
